//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package com.andromeda.androbench2;

import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.app.AlertDialog.Builder;
import android.content.ContentValues;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.DialogInterface.OnClickListener;
import android.content.SharedPreferences.Editor;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.res.AssetManager;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.graphics.Typeface;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.os.Build.VERSION;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.AdapterView.OnItemClickListener;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.GregorianCalendar;

import org.apache.http.NameValuePair;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.params.HttpConnectionParams;
import org.apache.http.params.HttpParams;
import org.apache.http.util.EntityUtils;

public class Result extends CustomActivity {
    private static final int KBYTE = 1024;
    private static final int MBYTE = 1048576;
    private static final int PROC_INIT = 0;
    private static final int PROC_INIT_PURGE = 6;
    private static final int PROC_MAKE_GRAPH = 5;
    private static final int PROC_PURGE_CACHE = 7;
    private static final int PROC_RND_READ = 3;
    private static final int PROC_RND_WRITE = 4;
    private static final int PROC_SEQ_READ = 1;
    private static final int PROC_SEQ_WRITE = 2;
    private static final int PROC_SQLITE_DELETE = 12;
    private static final int PROC_SQLITE_INIT = 8;
    private static final int PROC_SQLITE_INSERT = 9;
    private static final int PROC_SQLITE_UPDATE = 11;
    private static final int number_of_testing = 3;
    private ArrayList<Testing_Data> alTesting;
    double avg_perf_iops_rr = 0.0D;
    double avg_perf_iops_rw = 0.0D;
    double avg_perf_mbps_rr = 0.0D;
    double avg_perf_mbps_rw = 0.0D;
    double avg_perf_mbps_sr = 0.0D;
    double avg_perf_mbps_sw = 0.0D;
    double avg_perf_sqlite_delete = 0.0D;
    double avg_perf_sqlite_insert = 0.0D;
    double avg_perf_sqlite_update = 0.0D;
    double avg_sec_sqlite_delete = 0.0D;
    double avg_sec_sqlite_insert = 0.0D;
    double avg_sec_sqlite_update = 0.0D;
    int cntTesting;
    int databaseSize;
    private SQLiteDatabase dbTesting;
    private DeviceDB deviceDBHelper;
    ProgressDialog dlg_bench_progress;
    Builder dlg_bld_proc_bench;
    Builder dlg_bld_snd_result;
    boolean flag_microbench = false;
    int flag_process_type = 0;
    boolean flag_sqlitebench = false;
    private HistoryDB historyDBHelper;
    boolean indexUsage;
    String journalMode;
    private ListView lvTesting;
    Result.Thread_Benchmark mBenchmark;
    Context mContext;
    Result.Thread_SND_Result mSendResult;
    double perf_iops = 0.0D;
    double perf_mbps = 0.0D;
    boolean processing;
    long[] rnd_read_time = new long[3];
    long[] rnd_write_time = new long[3];
    boolean send_success_micro;
    boolean send_success_sqlite;
    long[] seq_read_time = new long[3];
    long[] seq_write_time = new long[3];
    SharedPreferences sp_Data;
    SharedPreferences sp_Flag;
    Editor sp_e_Data;
    Editor sp_e_Flag;
    long[] sqlite_delete_time = new long[3];
    long[] sqlite_insert_time = new long[3];
    long[] sqlite_update_time = new long[3];
    boolean starting;
    private Result.TestingAdapter taTesting;
    private Testing_SQLite_DBHelper testSQLite;
    int test_buffer_size_rnd;
    int test_buffer_size_seq;
    int test_file_flag;
    int test_file_size_read;
    int test_file_size_write;
    int test_num_sqlite;
    int test_num_thread;
    int test_one_file_size;
    String test_path;
    int test_random_seed;
    int test_rnd_recs;
    int test_target;
    int test_total_file_size;
    int test_use_fbe;
    Toast toast;
    double total_perf_iops = 0.0D;
    double total_perf_mbps = 0.0D;
    int transactionSize;
    String typeFileSystem;

    static {
        System.loadLibrary("Interface_JNI");
    }

    public Result() {
    }

    private void doBenchmarking() {
        this.mBenchmark = new Result.Thread_Benchmark();
        this.mBenchmark.start();
    }

    private void initBenchENV() {
        System.out.println("[initBenchENV]");
        this.test_target = this.sp_Data.getInt("TargetDevice", 0);
        this.test_buffer_size_seq = this.sp_Data.getInt("BufferSize_SEQ", 0);
        this.test_buffer_size_rnd = this.sp_Data.getInt("BufferSize_RND", 0);
        this.test_num_thread = this.sp_Data.getInt("Num_Thread", 0);
        this.test_rnd_recs = this.sp_Data.getInt("TestRecs_RAND", 0);
        this.test_use_fbe = 0;
        this.test_one_file_size = this.sp_Data.getInt("OneFileSize", 0);
        this.test_total_file_size = this.test_one_file_size * this.test_num_thread;
        this.test_file_size_read = this.test_total_file_size;
        this.test_file_size_write = this.test_total_file_size;
        this.test_num_sqlite = this.sp_Data.getInt("Num_Sqlite", 2048);
        this.databaseSize = this.sp_Data.getInt("DatabaseSize", 8);
        this.transactionSize = this.sp_Data.getInt("TransactionSize", 1);
        this.journalMode = this.sp_Data.getString("JournalMode", "WAL");
        boolean var1;
        if (this.sp_Data.getInt("IndexUsage", 1) == 1) {
            var1 = true;
        } else {
            var1 = false;
        }

        this.indexUsage = var1;
        if (this.test_target == 0) {
            this.test_path = this.getFilesDir().toString();
            this.typeFileSystem = MemoryStatus.getInternalFilesystem();
        } else {
            this.test_path = this.getExternalFilesDir((String) null).toString();
            this.test_path = this.test_path.replaceFirst(Environment.getExternalStorageDirectory().getAbsolutePath(), MemoryStatus.getSDExternalPath(this.mContext));
            this.typeFileSystem = MemoryStatus.getSDExternalFilesystem(this.mContext);
        }

        if (!this.typeFileSystem.equals("yaffs") && !this.typeFileSystem.equals("yaffs2") && !this.typeFileSystem.equals("ext2")) {
            this.test_file_flag = 1;
        } else {
            this.test_file_flag = 0;
        }
    }

    private void initResult() {
        this.alTesting.clear();
        this.alTesting.add(new Testing_Data("Sequential Read", "n/a"));
        this.alTesting.add(new Testing_Data("Sequential Write", "n/a"));
        this.alTesting.add(new Testing_Data("Random Read", "n/a"));
        this.alTesting.add(new Testing_Data("Random Write", "n/a"));
        this.alTesting.add(new Testing_Data("SQLite Insert", "n/a"));
        this.alTesting.add(new Testing_Data("SQLite Update", "n/a"));
        this.alTesting.add(new Testing_Data("SQLite Delete", "n/a"));
        this.lvTesting.setAdapter(this.taTesting);
    }

    private void printResult() {
        this.alTesting.clear();
        if (this.flag_microbench) {
            this.alTesting.add(new Testing_Data("Sequential Read", this.avg_perf_mbps_sr + " MB/s"));
            this.alTesting.add(new Testing_Data("Sequential Write", this.avg_perf_mbps_sw + " MB/s"));
            this.alTesting.add(new Testing_Data("Random Read", this.avg_perf_mbps_rr + " MB/s, " + this.avg_perf_iops_rr + " IOPS (" + this.test_buffer_size_rnd + "KB)"));
            this.alTesting.add(new Testing_Data("Random Write", this.avg_perf_mbps_rw + " MB/s, " + this.avg_perf_iops_rw + " IOPS (" + this.test_buffer_size_rnd + "KB)"));
        } else {
            this.alTesting.add(new Testing_Data("Sequential Read", "n/a"));
            this.alTesting.add(new Testing_Data("Sequential Write", "n/a"));
            this.alTesting.add(new Testing_Data("Random Read", "n/a"));
            this.alTesting.add(new Testing_Data("Random Write", "n/a"));
        }

        if (this.flag_sqlitebench) {
            this.alTesting.add(new Testing_Data("SQLite Insert", this.avg_perf_sqlite_insert + " QPS, " + this.avg_sec_sqlite_insert + " sec"));
            this.alTesting.add(new Testing_Data("SQLite Update", this.avg_perf_sqlite_update + " QPS, " + this.avg_sec_sqlite_update + " sec"));
            this.alTesting.add(new Testing_Data("SQLite Delete", this.avg_perf_sqlite_delete + " QPS, " + this.avg_sec_sqlite_delete + " sec"));
        } else {
            this.alTesting.add(new Testing_Data("SQLite Insert", "n/a"));
            this.alTesting.add(new Testing_Data("SQLite Update", "n/a"));
            this.alTesting.add(new Testing_Data("SQLite Delete", "n/a"));
        }

        this.lvTesting.setAdapter(this.taTesting);
    }

    void ERROR_CHECK(long var1) {
        System.out.println("[ERROR_CHECK] :");
        if (var1 == -1L) {
            Log.d("AndroBench_Error", "ERROR_NOT_OPEN");
            this.toast.setText("ERROR_NOT_OPEN");
            this.toast.show();
        } else {
            if (var1 == -2L) {
                Log.d("AndroBench_Error", "ERROR_NOT_READ");
                this.toast.setText("ERROR_NOT_READ");
                this.toast.show();
                return;
            }

            if (var1 == -3L) {
                Log.d("AndroBench_Error", "ERROR_NOT_WRITE");
                this.toast.setText("ERROR_NOT_WRITE");
                this.toast.show();
                return;
            }

            if (var1 == -4L) {
                Log.d("AndroBench_Error", "ERROR_NOT_ALLOCATION");
                this.toast.setText("ERROR_NOT_ALLOCATION");
                this.toast.show();
                return;
            }

            if (var1 == -5L) {
                Log.d("AndroBench_Error", "ERROR_NOT_CLOSE");
                this.toast.setText("ERROR_NOT_CLOSE");
                this.toast.show();
                return;
            }

            if (var1 == -6L) {
                Log.d("AndroBench_Error", "ERROR_NOT_CREATE_RNDNUM");
                this.toast.setText("ERROR_NOT_CREATE_RNDNUM");
                this.toast.show();
                return;
            }

            if (var1 < 0L) {
                Log.d("AndroBench_Error", "" + var1);
                this.toast.setText("ERROR " + var1);
                this.toast.show();
                return;
            }
        }

    }

    public native int FINAL(int var1, String var2, int var3);

    public native long GET_RND_REC_CNT();

    public native long GET_RND_REC_CNT_EACH(int var1);

    public native int INIT(int var1, String var2, int var3, int var4, int var5, int var6);

    public native int INIT_PURGE_CACHE(int var1);

    void ItemClick(AdapterView<?> var1, View var2, int var3, long var4) {
        Intent var6 = new Intent(this, Ranking.class);
        if (var3 == 0) {
            var6.putExtra("type", "v_avg_sr");
            if (this.avg_perf_mbps_sr != 0.0D) {
                var6.putExtra("flag_test", true);
                var6.putExtra("result", this.avg_perf_mbps_sr);
            } else {
                var6.putExtra("flag_test", false);
            }

            this.startActivity(var6);
        } else {
            if (var3 == 1) {
                var6.putExtra("type", "v_avg_sw");
                if (this.avg_perf_mbps_sw != 0.0D) {
                    var6.putExtra("flag_test", true);
                    var6.putExtra("result", this.avg_perf_mbps_sw);
                } else {
                    var6.putExtra("flag_test", false);
                }

                this.startActivity(var6);
                return;
            }

            if (var3 == 2) {
                var6.putExtra("type", "v_avg_rr");
                if (this.avg_perf_iops_rr != 0.0D) {
                    var6.putExtra("flag_test", true);
                    var6.putExtra("result", this.avg_perf_iops_rr);
                } else {
                    var6.putExtra("flag_test", false);
                }

                this.startActivity(var6);
                return;
            }

            if (var3 == 3) {
                var6.putExtra("type", "v_avg_rw");
                if (this.avg_perf_iops_rw != 0.0D) {
                    var6.putExtra("flag_test", true);
                    var6.putExtra("result", this.avg_perf_iops_rw);
                } else {
                    var6.putExtra("flag_test", false);
                }

                this.startActivity(var6);
                return;
            }

            if (var3 == 4) {
                var6.putExtra("type", "v_avg_insert");
                if (this.avg_perf_sqlite_insert != 0.0D) {
                    var6.putExtra("flag_test", true);
                    var6.putExtra("result", this.avg_perf_sqlite_insert);
                } else {
                    var6.putExtra("flag_test", false);
                }

                this.startActivity(var6);
                return;
            }

            if (var3 == 5) {
                var6.putExtra("type", "v_avg_update");
                if (this.avg_perf_sqlite_update != 0.0D) {
                    var6.putExtra("flag_test", true);
                    var6.putExtra("result", this.avg_perf_sqlite_update);
                } else {
                    var6.putExtra("flag_test", false);
                }

                this.startActivity(var6);
                return;
            }

            if (var3 == 6) {
                var6.putExtra("type", "v_avg_delete");
                if (this.avg_perf_sqlite_delete != 0.0D) {
                    var6.putExtra("flag_test", true);
                    var6.putExtra("result", this.avg_perf_sqlite_delete);
                } else {
                    var6.putExtra("flag_test", false);
                }

                this.startActivity(var6);
                return;
            }
        }

    }

    public native void PURGE_CACHE(int var1);//清除cache

    public native long RND_READ(int var1, String var2, int var3, int var4, int var5, int var6, int var7, int var8, int var9);

    public native long RND_WRITE(int var1, String var2, int var3, int var4, int var5, int var6, int var7, int var8, int var9);

    public native long SEQ_READ(int var1, String var2, int var3, int var4, int var5, int var6, int var7, int var8);

    public native long SEQ_WRITE(int var1, String var2, int var3, int var4, int var5, int var6, int var7, int var8);

    public void changeDialog(final int var1, final int var2) {
        this.runOnUiThread(new Runnable() {
            public void run() {
                if (Result.this.cntTesting == 3) {
                    Result var1x = Result.this;
                    var1x.cntTesting += -1;
                }

                switch (var1) {
                    case 0:
                        Result.this.dlg_bench_progress.setMessage("Initializing Files");
                        Result.this.dlg_bench_progress.setMax(Result.this.test_total_file_size);
                        Result.this.dlg_bench_progress.setProgress(var2);
                        return;
                    case 1:
                        Result.this.dlg_bench_progress.setMessage("Sequential Reading (" + (1 + Result.this.cntTesting) + "/" + 3 + ")");
                        Result.this.dlg_bench_progress.setMax(Result.this.test_num_thread * (Result.this.test_one_file_size - Result.this.test_one_file_size % Result.this.test_buffer_size_seq));
                        Result.this.dlg_bench_progress.setProgress(var2);
                        return;
                    case 2:
                        Result.this.dlg_bench_progress.setMessage("Sequential Writing (" + (1 + Result.this.cntTesting) + "/" + 3 + ")");
                        Result.this.dlg_bench_progress.setMax(Result.this.test_num_thread *
                                (Result.this.test_one_file_size - Result.this.test_one_file_size % Result.this.test_buffer_size_seq));
                        Result.this.dlg_bench_progress.setProgress(var2);
                        return;
                    case 3:
                        Result.this.dlg_bench_progress.setMessage("Random Reading (" + (1 + Result.this.cntTesting) + "/" + 3 + ")");
                        Result.this.dlg_bench_progress.setMax(Result.this.test_num_thread * Result.this.test_rnd_recs * Result.this.test_buffer_size_rnd);
                        Result.this.dlg_bench_progress.setProgress(var2);
                        return;
                    case 4:
                        Result.this.dlg_bench_progress.setMessage("Random Writing (" + (1 + Result.this.cntTesting) + "/" + 3 + ")");
                        Result.this.dlg_bench_progress.setMax(Result.this.test_num_thread * Result.this.test_rnd_recs * Result.this.test_buffer_size_rnd);
                        Result.this.dlg_bench_progress.setProgress(var2);
                        return;
                    case 5:
                    case 10:
                    default:
                        return;
                    case 6:
                        Result.this.dlg_bench_progress.setMessage("Initializing for Purge Cache");
                        Result.this.dlg_bench_progress.setMax(1048576 * (50 + MemoryStatus.getTotalMem() / 1024 / 2));
                        Result.this.dlg_bench_progress.setProgress(var2);
                        return;
                    case 7:
                        Result.this.dlg_bench_progress.setMessage("Purge Buffer Cache");
                        Result.this.dlg_bench_progress.setMax(1048576 * (50 + MemoryStatus.getTotalMem() / 1024 / 2));
                        Result.this.dlg_bench_progress.setProgress(var2);
                        return;
                    case 8:
                        Result.this.dlg_bench_progress.setMessage("Initializing SQLite Database");
                        Result.this.dlg_bench_progress.setMax(Result.this.test_num_sqlite * Result.this.databaseSize);
                        Result.this.dlg_bench_progress.setProgress(var2);
                        return;
                    case 9:
                        Result.this.dlg_bench_progress.setMessage("SQLite Insert (" + (1 + Result.this.cntTesting) + "/" + 3 + ")");
                        Result.this.dlg_bench_progress.setMax(Result.this.test_num_sqlite);
                        Result.this.dlg_bench_progress.setProgress(var2);
                        return;
                    case 11:
                        Result.this.dlg_bench_progress.setMessage("SQLite Update (" + (1 + Result.this.cntTesting) + "/" + 3 + ")");
                        Result.this.dlg_bench_progress.setMax(Result.this.test_num_sqlite);
                        Result.this.dlg_bench_progress.setProgress(var2);
                        return;
                    case 12:
                        Result.this.dlg_bench_progress.setMessage("SQLite Delete (" + (1 + Result.this.cntTesting) + "/" + 3 + ")");
                        Result.this.dlg_bench_progress.setMax(Result.this.test_num_sqlite);
                        Result.this.dlg_bench_progress.setProgress(var2);
                }
            }
        });
    }

    public void clearResult() {
        this.processing = false;
        this.sp_e_Flag.remove("StartingBench");
        this.sp_e_Flag.putBoolean("StartingBench", false);
        this.sp_e_Flag.commit();
    }

    public void copyReadme(AssetManager var1) {
        File var2 = new File("/sdcard/.androbench/readme.txt");

        Exception var3;
        label66:
        {
            InputStream var4;
            BufferedInputStream var5;
            FileOutputStream var6;
            Exception var10000;
            boolean var10001;
            label61:
            {
                label60:
                {
                    try {
                        var4 = var1.open("readme.txt");
                        var5 = new BufferedInputStream(var4);
                        if (var2.exists()) {
                            var2.delete();
                            var2.createNewFile();
                        }
                    } catch (IOException var16) {
                        var10000 = var16;
                        var10001 = false;
                        break label60;
                    }

                    try {
                        var6 = new FileOutputStream(var2);
                        break label61;
                    } catch (IOException var15) {
                        var10000 = var15;
                        var10001 = false;
                    }
                }

                var3 = var10000;
                break label66;
            }

            BufferedOutputStream var7;
            try {
                var7 = new BufferedOutputStream(var6);
            } catch (Exception var14) {
                var3 = var14;
                break label66;
            }

            label49:
            {
                byte[] var8;
                try {
                    var8 = new byte[1024];
                } catch (Exception var13) {
                    var10000 = var13;
                    var10001 = false;
                    break label49;
                }

                while (true) {
                    int var9;
                    try {
                        var9 = var5.read(var8, 0, 1024);
                    } catch (IOException var11) {
                        var10000 = var11;
                        var10001 = false;
                        break;
                    }

                    if (var9 == -1) {
                        try {
                            var7.flush();
                            var6.close();
                            var7.close();
                            var4.close();
                            var5.close();
                            return;
                        } catch (IOException var10) {
                            var10000 = var10;
                            var10001 = false;
                            break;
                        }
                    }

                    try {
                        var7.write(var8, 0, var9);
                    } catch (IOException var12) {
                        var10000 = var12;
                        var10001 = false;
                        break;
                    }
                }
            }

            var3 = var10000;
        }

        var3.printStackTrace();
    }

    void deleteDir(int var1, String var2) {
        File var3 = new File(var2 + "/script");
        File[] var4 = var3.listFiles();
        if (var4 != null) {
            int var6 = var4.length;

            for (int var7 = 0; var7 < var6; ++var7) {
                var4[var7].delete();
            }
        }

        var3.delete();
    }

    public void onCreate(Bundle var1) {
        super.onCreate(var1);
        this.setRequestedOrientation(1);
        this.setContentView(R.layout.result);
        this.dlg_bench_progress = new ProgressDialog(this);
        if (AndroBench.SDK_VERSION >= 21) {
            this.dlg_bench_progress.setProgressDrawable(this.getApplicationContext().getDrawable(R.drawable.custom_progressbar));
        } else {
            this.dlg_bench_progress.setProgressDrawable(this.getApplicationContext().getResources().getDrawable(R.drawable.custom_progressbar));
        }

        this.historyDBHelper = new HistoryDB(this, (String) null, (CursorFactory) null);
        this.deviceDBHelper = new DeviceDB(this, (String) null, (CursorFactory) null);
        this.sp_Data = this.getSharedPreferences("Settings", 0);
        this.sp_Flag = this.getSharedPreferences("Flags", 0);
        this.sp_e_Flag = this.sp_Flag.edit();
        this.lvTesting = (ListView) this.findViewById(R.id.TestingView);
        this.lvTesting.setOnItemClickListener(new OnItemClickListener() {
            public void onItemClick(AdapterView<?> var1, View var2, int var3, long var4) {
                Result.this.ItemClick(var1, var2, var3, var4);
            }
        });
        this.alTesting = new ArrayList();
        this.alTesting.clear();
        this.alTesting.add(new Testing_Data("Sequential Read", "n/a"));
        this.alTesting.add(new Testing_Data("Sequential Write", "n/a"));
        this.alTesting.add(new Testing_Data("Random Read", "n/a"));
        this.alTesting.add(new Testing_Data("Random Write", "n/a"));
        this.alTesting.add(new Testing_Data("SQLite Insert", "n/a"));
        this.alTesting.add(new Testing_Data("SQLite Update", "n/a"));
        this.alTesting.add(new Testing_Data("SQLite Delete", "n/a"));
        this.taTesting = new Result.TestingAdapter(this, R.layout.row_testing, this.alTesting);
        this.lvTesting.setAdapter(this.taTesting);
    }

    public void onDestroy() {
        super.onDestroy();
        this.historyDBHelper.close();
        this.deviceDBHelper.close();
    }

    protected void onRestoreInstanceState(Bundle var1) {
        super.onRestoreInstanceState(var1);
        this.processing = var1.getBoolean("processing");
    }

    protected void onResume() {
        super.onResume();
        this.mContext = this.getApplicationContext();
        this.dlg_bld_proc_bench = new Builder(this);
        this.dlg_bld_proc_bench.setCancelable(false).setPositiveButton("Yes", new OnClickListener() {
            public void onClick(DialogInterface var1, int var2) {
                if (Result.this.flag_process_type == 0) {
                    Result.this.startingDialog();
                    Result.this.doBenchmarking();
                } else {
                    Result.this.sp_e_Flag.remove("StartingBench");
                    Result.this.sp_e_Flag.putBoolean("StartingBench", false);
                    Result.this.sp_e_Flag.commit();
                    Intent var6 = new Intent();
                    var6.setAction("com.androbench.CHANGE_TAB");
                    var6.putExtra("CHANGE_TARGET", 3);
                    Result.this.sendBroadcast(var6);
                }
            }
        }).setNegativeButton("No", new OnClickListener() {
            public void onClick(DialogInterface var1, int var2) {
                Result.this.clearResult();
            }
        });
        this.dlg_bld_snd_result = new Builder(this);
        this.dlg_bld_snd_result.setCancelable(false).setTitle("Send Results")
                .setMessage("Benchmark results will be sent to the server for research purpose.\n" +
                        "No personally identifiable information will be transmitted.\n\nDo you want to continue?").
                setPositiveButton("Submit", new OnClickListener() {
            public void onClick(DialogInterface var1, int var2) {
                Result.this.mSendResult = Result.this.new Thread_SND_Result();
                Result.this.mSendResult.start();
            }
        }).setNegativeButton("Cancel", new OnClickListener() {
            public void onClick(DialogInterface var1, int var2) {
            }
        });
        this.starting = this.sp_Flag.getBoolean("StartingBench", false);
        this.flag_microbench = this.sp_Flag.getBoolean("MicroBench", false);
        this.flag_sqlitebench = this.sp_Flag.getBoolean("SqliteBench", false);
        if (!this.processing && this.starting) {
            this.initBenchENV();
            this.startingDialog();
            this.doBenchmarking();
        }

    }

    protected void onSaveInstanceState(Bundle var1) {
        super.onSaveInstanceState(var1);
        var1.putBoolean("processing", this.processing);
    }

    void runAsRoot(String var1) {
        try {
            Process var3 = Runtime.getRuntime().exec("su");
            DataOutputStream var4 = new DataOutputStream(var3.getOutputStream());
            var4.writeBytes(var1 + "\n");
            var4.writeBytes("exit\n");
            var4.flush();
            var3.destroy();
        } catch (IOException var5) {
            var5.printStackTrace();
        }
    }

    public void startingDialog() {
        this.dlg_bench_progress.setCancelable(false);
        this.dlg_bench_progress.setProgressStyle(1);
        this.dlg_bench_progress.setMessage(" ");
        this.dlg_bench_progress.setProgress(0);
        this.dlg_bench_progress.setMax(100);
        this.dlg_bench_progress.show();
        CustomActivity.setSelector((ViewGroup) this.dlg_bench_progress.getWindow().getDecorView());
        CustomActivity.setGlobalFont((ViewGroup) this.dlg_bench_progress.getWindow().getDecorView());
    }

    private class TestingAdapter extends BaseAdapter {
        Context ctx;
        int itemLayout;
        ArrayList<Testing_Data> list;

        TestingAdapter(Context var2, int var3, ArrayList<Testing_Data> var4) {
            this.ctx = var2;
            this.itemLayout = var3;
            this.list = var4;
        }

        public int getCount() {
            return this.list.size();
        }

        public Object getItem(int var1) {
            return this.list.get(var1);
        }

        public long getItemId(int var1) {
            return (long) var1;
        }

        public View getView(int var1, View var2, ViewGroup var3) {
            Result.TestingAdapter.ViewHolder var4 = new Result.TestingAdapter.ViewHolder();
            if (var2 == null) {
                var2 = ((LayoutInflater) this.ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(this.itemLayout, var3, false);
                var4.name = (TextView) var2.findViewById(R.id.row_testing_name);
                var4.status = (TextView) var2.findViewById(R.id.row_testing_status);
                var4.btn = (TextView) var2.findViewById(R.id.row_testing_btn);
                var2.setTag(var4);
            } else {
                var4 = (Result.TestingAdapter.ViewHolder) var2.getTag();
            }

            var4.name.setText(((Testing_Data) this.list.get(var1)).getName());
            var4.status.setText(((Testing_Data) this.list.get(var1)).getStatus());
            var4.name.setTypeface(Typeface.createFromAsset(Result.this.getApplicationContext().getAssets(), "fonts/PT_Sans-Web-Regular.ttf"));
            var4.status.setTypeface(Typeface.createFromAsset(Result.this.getApplicationContext().getAssets(), "fonts/PT_Sans-Web-Regular.ttf"));
            var4.btn.setTypeface(Typeface.createFromAsset(Result.this.getApplicationContext().getAssets(), "fonts/PT_Sans-Web-Regular.ttf"));
            return var2;
        }

        class ViewHolder {
            TextView btn;
            TextView name;
            TextView status;

            ViewHolder() {
            }
        }
    }

    public class Thread_Benchmark extends Thread {
        public Thread_Benchmark() {
        }

        public void microExecute() {
            Result.this.changeDialog(0, 0);
            int var1 = Result.this.INIT(Result.this.test_target, Result.this.test_path,
                    Result.this.test_file_flag, 1024,
                    Result.this.test_one_file_size, Result.this.test_num_thread);
            if (var1 == 1) {
                Result.this.test_use_fbe = 1;
            }

            System.out.println("use_fbe: " + Result.this.test_use_fbe);
            if (var1 == -1) {
                if (Result.this.test_target == 0) {
                    Result.this.toast.setText("ERROR_NOT_OPEN");
                } else {
                    Result.this.toast.setText("ERROR_NOT_OPEN");
                }

                Result.this.toast.show();
            } else if (var1 == -2) {
                Result.this.toast.setText("ERROR_NOT_READ");
                Result.this.toast.show();
            } else if (var1 == -3) {
                if (Result.this.test_target == 0) {
                    Result.this.toast.setText("ERROR_NOT_WRITE");
                } else {
                    Result.this.toast.setText("ERROR_NOT_WRITE");
                }

                Result.this.toast.show();
            } else if (var1 == -4) {
                Result.this.toast.setText("ERROR_NOT_ALLOCATION");
                Result.this.toast.show();
            } else if (var1 < 0) {
                Result.this.toast.setText("ERROR " + var1);
                Result.this.toast.show();
            }

            if (Result.this.test_file_flag == 0) {
                Result.this.INIT_PURGE_CACHE(1048576 * (50 + MemoryStatus.getTotalMem() / 1024 / 2));
                Result.this.copyReadme(Result.this.mContext.getAssets());
            }

            Result.this.total_perf_mbps = 0.0D;
            Result.this.total_perf_iops = 0.0D;

            Result var15;
            for (Result.this.cntTesting = 0; Result.this.cntTesting < 3; ++var15.cntTesting) {
                if (Result.this.test_file_flag == 0) {
                    Result.this.PURGE_CACHE(1048576 * (50 + MemoryStatus.getTotalMem() / 1024 / 2));
                }

                Result.this.seq_read_time[Result.this.cntTesting] = Result.this.SEQ_READ(Result.this.test_target, Result.this.test_path,
                        Result.this.test_file_flag, Result.this.test_buffer_size_seq, Result.this.test_file_size_read,
                        Result.this.test_one_file_size - Result.this.test_one_file_size % Result.this.test_buffer_size_seq,
                        Result.this.test_num_thread, Result.this.test_use_fbe);
                if (Result.this.seq_read_time[Result.this.cntTesting] == -1L) {
                    if (Result.this.test_target == 0) {
                        Result.this.toast.setText("ERROR_NOT_OPEN");
                    } else {
                        Result.this.toast.setText("ERROR_NOT_OPEN");
                    }

                    Result.this.toast.show();
                    break;
                }

                if (Result.this.seq_read_time[Result.this.cntTesting] == -2L) {
                    if (Result.this.test_target == 0) {
                        Result.this.toast.setText("ERROR_NOT_READ");
                    } else {
                        Result.this.toast.setText("ERROR_NOT_READ");
                    }

                    Result.this.toast.show();
                    break;
                }

                if (Result.this.seq_read_time[Result.this.cntTesting] == -3L) {
                    Result.this.toast.setText("ERROR_NOT_WRITE");
                    Result.this.toast.show();
                    break;
                }

                if (Result.this.seq_read_time[Result.this.cntTesting] == -4L) {
                    Result.this.toast.setText("ERROR_NOT_ALLOCATION");
                    Result.this.toast.show();
                    break;
                }

                if (Result.this.seq_read_time[Result.this.cntTesting] < 0L) {
                    Result.this.toast.setText("ERROR " + Result.this.seq_read_time[Result.this.cntTesting]);
                    Result.this.toast.show();
                    break;
                }

                Result.this.perf_mbps = (double) (Result.this.test_num_thread *
                        (Result.this.test_one_file_size - Result.this.test_one_file_size % Result.this.test_buffer_size_seq)) / 1024.0D /
                        ((double) Result.this.seq_read_time[Result.this.cntTesting] / 1000000.0D);
                Result var14 = Result.this;
                var14.total_perf_mbps += Result.this.perf_mbps;
                Result.this.avg_perf_mbps_sr = (double) ((int) (100.0D * (Result.this.total_perf_mbps / (double) (1 + Result.this.cntTesting)))) / 100.0D;
                var15 = Result.this;
            }

            Result.this.total_perf_mbps = 0.0D;
            Result.this.total_perf_iops = 0.0D;

            Result var13;
            for (Result.this.cntTesting = 0; Result.this.cntTesting < 3; ++var13.cntTesting) {
                Result.this.seq_write_time[Result.this.cntTesting] = Result.this.SEQ_WRITE(Result.this.test_target, Result.this.test_path,
                        Result.this.test_file_flag, Result.this.test_buffer_size_seq,
                        Result.this.test_file_size_write, Result.this.test_one_file_size - Result.this.test_one_file_size % Result.this.test_buffer_size_seq,
                        Result.this.test_num_thread, Result.this.test_use_fbe);
                if (Result.this.seq_write_time[Result.this.cntTesting] == -1L) {
                    Result.this.toast.setText("ERROR_NOT_OPEN");
                    Result.this.toast.show();
                    break;
                }

                if (Result.this.seq_write_time[Result.this.cntTesting] == -2L) {
                    Result.this.toast.setText("ERROR_NOT_READ");
                    Result.this.toast.show();
                    break;
                }

                if (Result.this.seq_write_time[Result.this.cntTesting] == -3L) {
                    if (Result.this.test_target == 0) {
                        Result.this.toast.setText("ERROR_NOT_WRITE");
                    } else {
                        Result.this.toast.setText("ERROR_NOT_WRITE");
                    }

                    Result.this.toast.show();
                    break;
                }

                if (Result.this.seq_write_time[Result.this.cntTesting] == -4L) {
                    Result.this.toast.setText("ERROR_NOT_ALLOCATION");
                    Result.this.toast.show();
                    break;
                }

                if (Result.this.seq_write_time[Result.this.cntTesting] < 0L) {
                    Result.this.toast.setText("ERROR " + Result.this.seq_write_time[Result.this.cntTesting]);
                    Result.this.toast.show();
                    break;
                }

                Result.this.perf_mbps = (double) (Result.this.test_num_thread * (Result.this.test_one_file_size - Result.this.test_one_file_size % Result.this.test_buffer_size_seq)) / 1024.0D / ((double) Result.this.seq_write_time[Result.this.cntTesting] / 1000000.0D);
                Result var12 = Result.this;
                var12.total_perf_mbps += Result.this.perf_mbps;
                Result.this.avg_perf_mbps_sw = (double) ((int) (100.0D * (Result.this.total_perf_mbps / (double) (1 + Result.this.cntTesting)))) / 100.0D;
                var13 = Result.this;
            }

            Result.this.total_perf_mbps = 0.0D;
            Result.this.total_perf_iops = 0.0D;
            Result.this.test_random_seed = (int) (10000.0D * Math.random());

            Result var11;
            for (Result.this.cntTesting = 0; Result.this.cntTesting < 3; ++var11.cntTesting) {
                if (Result.this.test_file_flag == 0) {
                    Result.this.PURGE_CACHE(1048576 * (50 + MemoryStatus.getTotalMem() / 1024 / 2));
                }

                Result.this.rnd_read_time[Result.this.cntTesting] = Result.this.RND_READ(Result.this.test_target, Result.this.test_path, Result.this.test_file_flag, Result.this.test_buffer_size_rnd, Result.this.test_one_file_size, Result.this.test_rnd_recs, Result.this.test_random_seed, Result.this.test_num_thread, Result.this.test_use_fbe);
                if (Result.this.rnd_read_time[Result.this.cntTesting] == -1L) {
                    if (Result.this.test_target == 0) {
                        Result.this.toast.setText("ERROR_NOT_OPEN");
                    } else {
                        Result.this.toast.setText("ERROR_NOT_OPEN");
                    }

                    Result.this.toast.show();
                    break;
                }

                if (Result.this.rnd_read_time[Result.this.cntTesting] == -2L) {
                    if (Result.this.test_target == 0) {
                        Result.this.toast.setText("ERROR_NOT_READ");
                    } else {
                        Result.this.toast.setText("ERROR_NOT_READ");
                    }

                    Result.this.toast.show();
                    break;
                }

                if (Result.this.rnd_read_time[Result.this.cntTesting] == -3L) {
                    Result.this.toast.setText("ERROR_NOT_WRITE");
                    Result.this.toast.show();
                    break;
                }

                if (Result.this.rnd_read_time[Result.this.cntTesting] == -4L) {
                    Result.this.toast.setText("ERROR_NOT_ALLOCATION");
                    Result.this.toast.show();
                    break;
                }

                if (Result.this.rnd_read_time[Result.this.cntTesting] < 0L) {
                    Result.this.toast.setText("ERROR " + Result.this.rnd_read_time[Result.this.cntTesting]);
                    Result.this.toast.show();
                    break;
                }

                double var7 = (double) Result.this.GET_RND_REC_CNT();
                Result.this.perf_mbps = var7 * (double) Result.this.test_buffer_size_rnd / 1024.0D / ((double) Result.this.rnd_read_time[Result.this.cntTesting] / 1000000.0D);
                Result var9 = Result.this;
                var9.total_perf_mbps += Result.this.perf_mbps;
                Result.this.avg_perf_mbps_rr = (double) ((int) (100.0D * (Result.this.total_perf_mbps / (double) (1 + Result.this.cntTesting)))) / 100.0D;
                Result.this.perf_iops = var7 / ((double) Result.this.rnd_read_time[Result.this.cntTesting] / 1000000.0D);
                Result var10 = Result.this;
                var10.total_perf_iops += Result.this.perf_iops;
                Result.this.avg_perf_iops_rr = (double) ((int) (100.0D * (Result.this.total_perf_iops / (double) (1 + Result.this.cntTesting)))) / 100.0D;
                var11 = Result.this;
            }

            Result.this.total_perf_mbps = 0.0D;
            Result.this.total_perf_iops = 0.0D;
            Result.this.test_random_seed = (int) (10000.0D * Math.random());

            Result var6;
            for (Result.this.cntTesting = 0; Result.this.cntTesting < 3; ++var6.cntTesting) {
                Result.this.rnd_write_time[Result.this.cntTesting] = Result.this.RND_WRITE(Result.this.test_target, Result.this.test_path, Result.this.test_file_flag, Result.this.test_buffer_size_rnd, Result.this.test_one_file_size, Result.this.test_rnd_recs, Result.this.test_random_seed, Result.this.test_num_thread, Result.this.test_use_fbe);
                if (Result.this.rnd_write_time[Result.this.cntTesting] == -1L) {
                    Result.this.toast.setText("ERROR_NOT_OPEN");
                    Result.this.toast.show();
                    break;
                }

                if (Result.this.rnd_write_time[Result.this.cntTesting] == -2L) {
                    Result.this.toast.setText("ERROR_NOT_READ");
                    Result.this.toast.show();
                    return;
                }

                if (Result.this.rnd_write_time[Result.this.cntTesting] == -3L) {
                    if (Result.this.test_target == 0) {
                        Result.this.toast.setText("ERROR_NOT_WRITE");
                    } else {
                        Result.this.toast.setText("ERROR_NOT_WRITE");
                    }

                    Result.this.toast.show();
                    return;
                }

                if (Result.this.rnd_write_time[Result.this.cntTesting] == -4L) {
                    Result.this.toast.setText("ERROR_NOT_ALLOCATION");
                    Result.this.toast.show();
                    return;
                }

                if (Result.this.rnd_write_time[Result.this.cntTesting] < 0L) {
                    Result.this.toast.setText("ERROR " + Result.this.rnd_write_time[Result.this.cntTesting]);
                    Result.this.toast.show();
                    return;
                }

                double var2 = (double) Result.this.GET_RND_REC_CNT();
                Result.this.perf_mbps = var2 * (double) Result.this.test_buffer_size_rnd / 1024.0D / ((double) Result.this.rnd_write_time[Result.this.cntTesting] / 1000000.0D);
                Result var4 = Result.this;
                var4.total_perf_mbps += Result.this.perf_mbps;
                Result.this.avg_perf_mbps_rw = (double) ((int) (100.0D * (Result.this.total_perf_mbps / (double) (1 + Result.this.cntTesting)))) / 100.0D;
                Result.this.perf_iops = var2 / ((double) Result.this.rnd_write_time[Result.this.cntTesting] / 1000000.0D);
                Result var5 = Result.this;
                var5.total_perf_iops += Result.this.perf_iops;
                Result.this.avg_perf_iops_rw = (double) ((int) (100.0D * (Result.this.total_perf_iops / (double) (1 + Result.this.cntTesting)))) / 100.0D;
                var6 = Result.this;
            }

        }

        public void postExecute() {
            Result.this.dlg_bench_progress.dismiss();
            Result.this.runOnUiThread(new Runnable() {
                public void run() {
                    AlertDialog var1 = Result.this.dlg_bld_snd_result.create();
                    var1.show();
                    CustomActivity.setSelector((ViewGroup) var1.getWindow().getDecorView());
                    CustomActivity.setGlobalFont((ViewGroup) var1.getWindow().getDecorView());
                }
            });
            Result.this.runOnUiThread(new Runnable() {
                public void run() {
                    Result.this.printResult();
                }
            });
            GregorianCalendar var1 = new GregorianCalendar();
            Object[] var2 = new Object[]{var1.get(1), 1 + var1.get(2), var1.get(5), var1.get(11), var1.get(12), var1.get(13)};
            String var3 = String.format("%04d-%02d-%02d %02d:%02d:%02d", var2);
            String var4;
            if (Result.this.test_target == 0) {
                String var23 = MemoryStatus.getInternalFilesystem();
                String var24 = MemoryStatus.getInternalScheduler();
                if (var23.equals("unknown")) {
                    var23 = "-";
                }

                if (var24.equals("unknown")) {
                    var24 = "-";
                }

                StringBuilder var25 = (new StringBuilder()).append("/data (").append(var23);
                String var26;
                if (Result.this.test_use_fbe == 1) {
                    var26 = ", FBE, ";
                } else {
                    var26 = ", ";
                }

                var4 = var25.append(var26).append(var24).append(")").toString();
            } else if (Result.this.test_target == 1) {
                String var19 = MemoryStatus.getSDExternalFilesystem(Result.this.mContext);
                String var20 = MemoryStatus.getSDExternalScheduler();
                if (var19.equals("unknown")) {
                    var19 = "-";
                }

                if (var20.equals("unknown")) {
                    var20 = "-";
                }

                StringBuilder var21 = (new StringBuilder()).append(MemoryStatus.getSDExternalPath(Result.this.mContext)).append(" (").append(var19);
                String var22;
                if (Result.this.test_use_fbe == 1) {
                    var22 = ", FBE, ";
                } else {
                    var22 = ", ";
                }

                var4 = var21.append(var22).append(var20).append(")").toString();
            } else {
                var4 = "unknown";
            }

            String var5;
            if (Result.this.test_file_flag == 0) {
                var5 = "Yes(Purge)";
            } else {
                var5 = "No";
            }

            SQLiteDatabase var6 = Result.this.historyDBHelper.getWritableDatabase();
            ContentValues var7 = new ContentValues();
            var7.put("date", var3);
            var7.put("target", var4);
            var7.put("filesize_read", Result.this.test_file_size_read / 1024);
            var7.put("filesize_write", Result.this.test_file_size_write / 1024);
            var7.put("one_filesize", Result.this.test_one_file_size / 1024);
            var7.put("num_thread", Result.this.test_num_thread);
            var7.put("buffersize_seq", Result.this.test_buffer_size_seq);
            var7.put("buffersize_rnd", Result.this.test_buffer_size_rnd);
            var7.put("use_buffer", var5);
            var7.put("avg_mbps_sr", Result.this.avg_perf_mbps_sr);
            var7.put("avg_mbps_sw", Result.this.avg_perf_mbps_sw);
            var7.put("avg_mbps_rr", Result.this.avg_perf_mbps_rr);
            var7.put("avg_iops_rr", Result.this.avg_perf_iops_rr);
            var7.put("avg_mbps_rw", Result.this.avg_perf_mbps_rw);
            var7.put("avg_iops_rw", Result.this.avg_perf_iops_rw);
            var7.put("avg_perf_sqlite_insert", Result.this.avg_perf_sqlite_insert);
            var7.put("avg_perf_sqlite_update", Result.this.avg_perf_sqlite_update);
            var7.put("avg_perf_sqlite_delete", Result.this.avg_perf_sqlite_delete);
            var7.put("transaction_size", Result.this.transactionSize);
            var7.put("journal_mode", Result.this.journalMode);
            var7.put("index_usage", Result.this.indexUsage);
            var6.insert("history", (String) null, var7);
            Result.this.processing = false;
            Result.this.sp_e_Flag.remove("StartingBench");
            Result.this.sp_e_Flag.putBoolean("StartingBench", false);
            Result.this.sp_e_Flag.commit();
            Result.this.dbTesting.execSQL("DROP INDEX IF EXISTS friends_index;");
            Result.this.dbTesting.delete("friends", (String) null, (String[]) null);
            Cursor var14 = var6.rawQuery("PRAGMA WAL_CHECKPOINT(TRUNCATE)", (String[]) null);
            var14.moveToNext();
            System.out.println("wal_checkpoint ret: " + var14.getString(0));
            var14.close();
            SQLiteDatabase.releaseMemory();
            Result.this.dbTesting.close();
            Result.this.testSQLite.close();
            Result.this.getApplicationContext().deleteDatabase("testing_sqlite.db");
            Result.this.FINAL(Result.this.test_target, Result.this.test_path, Result.this.test_num_thread);
            Result.this.getWindow().clearFlags(128);
        }

        public void preExecute() {
            Result.this.getWindow().addFlags(128);
            Result.this.processing = true;
            Result.this.total_perf_mbps = 0.0D;
            Result.this.total_perf_iops = 0.0D;
            Result.this.avg_perf_mbps_sr = 0.0D;
            Result.this.avg_perf_mbps_sw = 0.0D;
            Result.this.avg_perf_mbps_rr = 0.0D;
            Result.this.avg_perf_mbps_rw = 0.0D;
            Result.this.avg_perf_iops_rr = 0.0D;
            Result.this.avg_perf_iops_rw = 0.0D;
            Result.this.avg_sec_sqlite_insert = 0.0D;
            Result.this.avg_sec_sqlite_update = 0.0D;
            Result.this.avg_sec_sqlite_delete = 0.0D;
            Result.this.avg_perf_sqlite_insert = 0.0D;
            Result.this.avg_perf_sqlite_update = 0.0D;
            Result.this.avg_perf_sqlite_delete = 0.0D;
            Result.this.runOnUiThread(new Runnable() {
                public void run() {
                    Result.this.initResult();
                }
            });
            Result.this.mContext.getFilesDir();
            Result.this.getApplicationContext().deleteDatabase("testing_sqlite.db");
            Result.this.testSQLite = new Testing_SQLite_DBHelper(Result.this.mContext, 2, Result.this.journalMode);
            Result.this.dbTesting = Result.this.testSQLite.getWritableDatabase();
            Result.this.dbTesting.execSQL("drop index if exists friends_index;");
            Result.this.dbTesting.delete("friends", (String) null, (String[]) null);
            SQLiteDatabase.releaseMemory();
        }

        public void run() {
            this.preExecute();
            if (Result.this.flag_microbench) {
                this.microExecute();
            }

            if (Result.this.flag_sqlitebench) {
                this.sqliteExecute();
            }

            this.postExecute();
        }

        public void sqliteExecute() {
            Result.this.changeDialog(9, 0);
            ArrayList var1 = new ArrayList();

            for (int var2 = 0; var2 < Result.this.test_num_sqlite * (3 + Result.this.databaseSize); ++var2) {
                var1.add(var2);
            }

            if (Result.this.indexUsage) {
                Result.this.dbTesting.execSQL("CREATE INDEX friends_index on friends (id);");
            }

            Cursor var3 = Result.this.dbTesting.rawQuery("PRAGMA JOURNAL_MODE", (String[]) null);
            var3.moveToNext();
            System.out.println("journal_mode=" + var3.getString(0));
            var3.close();
            SQLiteDatabase.releaseMemory();

            for (int var6 = 0; var6 < Result.this.test_num_sqlite * Result.this.databaseSize; ++var6) {
                if (var6 % 128 == 0) {
                    Result.this.dbTesting.beginTransaction();
                }

                Result.this.dbTesting.execSQL("INSERT INTO friends(position,phonetic_name,phone_number,member_type,contact_id,type,raw_phone_number,ext,chat_id,id,nick_name,brand_new,name,contact_name,created_at,blocked,original_profile_image_url,enc,account_id,user_type,status_message,favorite,involved_chat_ids,full_profile_image_url,new_badge_updated_at,v,hidden,new_badge_seen_at,uuid,profile_image_url,board_v) VALUES (0,NULL,'3KHUINqoyK803wdNY68MPQ==',1,170,2,'n1ZsqrK3CheYDBe4OtP8YQ==','+BtD/WmfOsUE9WOKF21BeA==',0," + var6 + ",'',0,'k3IH4ZbX9DyHHsSzJskzwg==','EHAJVx3YHJhy2hPHC8Nx2g==',1405230019612,0,'ckCrrKdHb3VXad3MuNwvQrcaj5zSp1Vbci6RYTPz4LtjzRgE0enbDG4QZi00DpGRKmCAU6TxSsGR5GfGwIG4+ppHEViDZ+yDW9ewE03SLy4=',3,26637883,0,'UfghQBtQKGzjTG4k9hV/2A==',0,'[]','+thltIAkixAjU9g+lj8Lev3pathtTTDL1WxaCnELIoXjE737HmHVwEFakiO89gdkUUJoAJp6b7t/qiCY/Xgd0jkiaTwTl/IgdDx8Ku3SWg3RqGHgvxINITYrZtBoYT6f',0,'+BtD/WmfOsUE9WOKF21BeA==',0,0,'9weDYX0il8OsK7AQoyo4/g==','+thltIAkixAjU9g+lj8Lev3pathtTTDL1WxaCnELIoXjE737HmHVwEFakiO89gdkUUJoAJp6b7t/qiCY/Xgd0l4m8FwLxth8NpVywFibj15/PIxHcBLB86VvjyNaaiWY','+BtD/WmfOsUE9WOKF21BeA==');");
                if ((var6 + 1) % 128 == 0 || var6 == -1 + Result.this.test_num_sqlite * Result.this.databaseSize) {
                    Result.this.dbTesting.setTransactionSuccessful();
                    Result.this.dbTesting.endTransaction();
                }

                Result.this.changeDialog(8, var6);
            }

            int var7 = Result.this.test_num_sqlite * Result.this.databaseSize;

            Result var35;
            for (Result.this.cntTesting = 0; Result.this.cntTesting < 3; ++var35.cntTesting) {
                SQLiteDatabase.releaseMemory();
                Result.this.sqlite_insert_time[Result.this.cntTesting] = 0L;

                for (int var28 = 0; var28 < Result.this.test_num_sqlite; ++var28) {
                    Date var29 = new Date();
                    if (var28 % Result.this.transactionSize == 0) {
                        Result.this.dbTesting.beginTransaction();
                    }

                    Result.this.dbTesting.execSQL("INSERT INTO friends(position,phonetic_name,phone_number,member_type,contact_id," +
                            "type,raw_phone_number,ext,chat_id,id,nick_name,brand_new,name,contact_name,created_at,blocked," +
                            "original_profile_image_url,enc,account_id,user_type,status_message,favorite,involved_chat_ids,full_profile_image_url," +
                            "new_badge_updated_at,v,hidden,new_badge_seen_at,uuid,profile_image_url,board_v) VALUES" +
                            " (0,NULL,'3KHUINqoyK803wdNY68MPQ==',1,170,2,'n1ZsqrK3CheYDBe4OtP8YQ==','+BtD/WmfOsUE9WOKF21BeA==',0," + var7 + var28 + "," +
                            "'',0,'k3IH4ZbX9DyHHsSzJskzwg==','EHAJVx3YHJhy2hPHC8Nx2g==',1405230019612,0," +
                            "'ckCrrKdHb3VXad3MuNwvQrcaj5zSp1Vbci6RYTPz4LtjzRgE0enbDG4QZi00DpGRKmCAU6TxSsGR5GfGwIG4+ppHEViDZ+yDW9ewE03SLy4='," +
                            "3,26637883,0,'UfghQBtQKGzjTG4k9hV/2A==',0,'[]'," +
                            "'+thltIAkixAjU9g+lj8Lev3pathtTTDL1WxaCnELIoXjE737HmHVwEFakiO89gdkUUJoAJp6b7t/qiCY/Xgd0jkiaTwTl/IgdDx8Ku3SWg3RqGHgvxINITYrZtBoYT6f'," +
                            "0,'+BtD/WmfOsUE9WOKF21BeA==',0,0,'9weDYX0il8OsK7AQoyo4/g=='," +
                            "'+thltIAkixAjU9g+lj8Lev3pathtTTDL1WxaCnELIoXjE737HmHVwEFakiO89gdkUUJoAJp6b7t/qiCY/Xgd0l4m8FwLxth8NpVywFibj15/PIxHcBLB86VvjyNaaiWY'," +
                            "'+BtD/WmfOsUE9WOKF21BeA==');");
                    if ((var28 + 1) % Result.this.transactionSize == 0 || var28 == -1 + Result.this.test_num_sqlite) {
                        Result.this.dbTesting.setTransactionSuccessful();
                        Result.this.dbTesting.endTransaction();
                    }

                    Date var30 = new Date();
                    long[] var31 = Result.this.sqlite_insert_time;
                    int var32 = Result.this.cntTesting;
                    var31[var32] += var30.getTime() - var29.getTime();
                    Result.this.changeDialog(9, var28);
                }

                Result var33 = Result.this;
                var33.avg_sec_sqlite_insert += (double) ((int) (100.0D * ((double) Result.this.sqlite_insert_time[Result.this.cntTesting] / 1000.0D))) / 100.0D;
                Result var34 = Result.this;
                var34.avg_perf_sqlite_insert += (double) ((int) (100.0D * ((double) Result.this.test_num_sqlite / ((double) Result.this.sqlite_insert_time[Result.this.cntTesting] / 1000.0D)))) / 100.0D;
                var7 += Result.this.test_num_sqlite;
                System.out.println("SQLite insert #" + (1 + Result.this.cntTesting) + ": " + Result.this.sqlite_insert_time[Result.this.cntTesting] + " sec");
                var35 = Result.this;
            }

            Result.this.avg_sec_sqlite_insert = (double) ((int) (100.0D * (Result.this.avg_sec_sqlite_insert / 3.0D))) / 100.0D;
            Result.this.avg_perf_sqlite_insert = (double) ((int) (100.0D * (Result.this.avg_perf_sqlite_insert / 3.0D))) / 100.0D;

            Result var26;
            for (Result.this.cntTesting = 0; Result.this.cntTesting < 3; ++var26.cntTesting) {
                SQLiteDatabase.releaseMemory();
                Result.this.sqlite_update_time[Result.this.cntTesting] = 0L;
                Collections.shuffle(var1);

                for (int var19 = 0; var19 < Result.this.test_num_sqlite; ++var19) {
                    Date var20 = new Date();
                    if (var19 % Result.this.transactionSize == 0) {
                        Result.this.dbTesting.beginTransaction();
                    }

                    Result.this.dbTesting.execSQL("UPDATE friends SET position=0,phonetic_name=NULL,phone_number='k0I6GC5/dY96EAav0rDvEA==',member_type=1,contact_id=267,type=2,raw_phone_number='RlJIgYhkkUGKgQzU3qYI1A==',ext='+BtD/WmfOsUE9WOKF21BeA==',chat_id=0,id=" + var1.get(var19) + ",nick_name='',brand_new=0,name='2ZV35tMjOOFhr53ebBaYkg==',contact_name='2ZV35tMjOOFhr53ebBaYkg==',created_at=1405231530055,blocked=0,original_profile_image_url='ckCrrKdHb3VXad3MuNwvQrcaj5zSp1Vbci6RYTPz4Lvf6n9hzIiF/B8s3TsdrgWJBXmGQhOWmjNsGWgOS3yNrx/jPCq7FQLdconv/NPa57w=',enc=3,account_id=33434186,user_type=0,status_message='',favorite=0,involved_chat_ids='[50680901071888]',full_profile_image_url='+thltIAkixAjU9g+lj8Lev3pathtTTDL1WxaCnELIoWC0mN0k7H3Jiy937Ps1hHGgui6Abq2RMNMQuuxkUPvmTvH8iXYSMKsnh6vp6ieEgjAfMYf5sYeC+sIHSytasDe',new_badge_updated_at=0,v='+BtD/WmfOsUE9WOKF21BeA==',hidden=0,new_badge_seen_at=0,uuid='',profile_image_url='+thltIAkixAjU9g+lj8Lev3pathtTTDL1WxaCnELIoWC0mN0k7H3Jiy937Ps1hHGgui6Abq2RMNMQuuxkUPvmeo1U2Nk1OWZecrDLe7nTG0I4g6tnddrpT0HMDl3cox+',board_v='+BtD/WmfOsUE9WOKF21BeA==' WHERE id=" + var1.get(var19) + ";");
                    if ((var19 + 1) % Result.this.transactionSize == 0 || var19 == -1 + Result.this.test_num_sqlite) {
                        Result.this.dbTesting.setTransactionSuccessful();
                        Result.this.dbTesting.endTransaction();
                    }

                    Date var21 = new Date();
                    long[] var22 = Result.this.sqlite_update_time;
                    int var23 = Result.this.cntTesting;
                    var22[var23] += var21.getTime() - var20.getTime();
                    Result.this.changeDialog(11, var19);
                }

                Result var24 = Result.this;
                var24.avg_sec_sqlite_update += (double) ((int) (100.0D * ((double) Result.this.sqlite_update_time[Result.this.cntTesting] / 1000.0D))) / 100.0D;
                Result var25 = Result.this;
                var25.avg_perf_sqlite_update += (double) ((int) (100.0D * ((double) Result.this.test_num_sqlite / ((double) Result.this.sqlite_update_time[Result.this.cntTesting] / 1000.0D)))) / 100.0D;
                System.out.println("SQLite update #" + (1 + Result.this.cntTesting) + ": " + Result.this.sqlite_update_time[Result.this.cntTesting] + " sec");
                var26 = Result.this;
            }

            Result.this.avg_sec_sqlite_update = (double) ((int) (100.0D * (Result.this.avg_sec_sqlite_update / 3.0D))) / 100.0D;
            Result.this.avg_perf_sqlite_update = (double) ((int) (100.0D * (Result.this.avg_perf_sqlite_update / 3.0D))) / 100.0D;
            Collections.shuffle(var1);
            int var8 = 0;

            Result var17;
            for (Result.this.cntTesting = 0; Result.this.cntTesting < 3; ++var17.cntTesting) {
                SQLiteDatabase.releaseMemory();
                Result.this.sqlite_delete_time[Result.this.cntTesting] = 0L;

                for (int var10 = 0; var10 < Result.this.test_num_sqlite; ++var10) {
                    Date var11 = new Date();
                    if (var10 % Result.this.transactionSize == 0) {
                        Result.this.dbTesting.beginTransaction();
                    }

                    Result.this.dbTesting.execSQL("DELETE FROM friends where id=" + var1.get(var8 + var10) + ";");
                    if ((var10 + 1) % Result.this.transactionSize == 0 || var10 == -1 + Result.this.test_num_sqlite) {
                        Result.this.dbTesting.setTransactionSuccessful();
                        Result.this.dbTesting.endTransaction();
                    }

                    Date var12 = new Date();
                    long[] var13 = Result.this.sqlite_delete_time;
                    int var14 = Result.this.cntTesting;
                    var13[var14] += var12.getTime() - var11.getTime();
                    Result.this.changeDialog(12, var10);
                }

                Result var15 = Result.this;
                var15.avg_sec_sqlite_delete += (double) ((int) (100.0D * ((double) Result.this.sqlite_delete_time[Result.this.cntTesting] / 1000.0D))) / 100.0D;
                Result var16 = Result.this;
                var16.avg_perf_sqlite_delete += (double) ((int) (100.0D * ((double) Result.this.test_num_sqlite / ((double) Result.this.sqlite_delete_time[Result.this.cntTesting] / 1000.0D)))) / 100.0D;
                System.out.println("SQLite delete #" + (1 + Result.this.cntTesting) + ": " + Result.this.sqlite_delete_time[Result.this.cntTesting] + " sec");
                var8 += Result.this.test_num_sqlite;
                var17 = Result.this;
            }

            Result.this.avg_sec_sqlite_delete = (double) ((int) (100.0D * (Result.this.avg_sec_sqlite_delete / 3.0D))) / 100.0D;
            Result.this.avg_perf_sqlite_delete = (double) ((int) (100.0D * (Result.this.avg_perf_sqlite_delete / 3.0D))) / 100.0D;
        }
    }

    public class Thread_SND_Result extends Thread {
        public Thread_SND_Result() {
        }

        public void run() {
            if (Result.this.flag_microbench) {
                int var23 = 0;
                Result.this.send_success_micro = false;
                ArrayList var24 = GetInfo.info_to_Arrs(Result.this.mContext, Result.this.test_target);

                for (int var25 = 0; var25 < var24.size(); ++var25) {
                    System.out.println(((NameValuePair) var24.get(var25)).toString());
                }

                var24.add(new BasicNameValuePair("num_thread", String.valueOf(Result.this.test_num_thread)));
                var24.add(new BasicNameValuePair("use_fbe", String.valueOf(Result.this.test_use_fbe)));
                var24.add(new BasicNameValuePair("filesize_per_thread", String.valueOf(Result.this.test_one_file_size)));
                var24.add(new BasicNameValuePair("rnd_ops_per_thread", String.valueOf(Result.this.test_rnd_recs)));
                var24.add(new BasicNameValuePair("buffersize_seq", String.valueOf(Result.this.test_buffer_size_seq)));
                var24.add(new BasicNameValuePair("buffersize_rnd", String.valueOf(Result.this.test_buffer_size_rnd)));
                var24.add(new BasicNameValuePair("avg_mbps_sr", String.valueOf(Result.this.avg_perf_mbps_sr)));
                var24.add(new BasicNameValuePair("avg_mbps_sw", String.valueOf(Result.this.avg_perf_mbps_sw)));
                var24.add(new BasicNameValuePair("avg_mbps_rr", String.valueOf(Result.this.avg_perf_mbps_rr)));
                var24.add(new BasicNameValuePair("avg_iops_rr", String.valueOf(Result.this.avg_perf_iops_rr)));
                var24.add(new BasicNameValuePair("avg_mbps_rw", String.valueOf(Result.this.avg_perf_mbps_rw)));
                var24.add(new BasicNameValuePair("avg_iops_rw", String.valueOf(Result.this.avg_perf_iops_rw)));

                for (; var23 < 3 && !Result.this.send_success_micro; ++var23) {
                    try {
                        CustomHttpClient var38 = new CustomHttpClient(Result.this.getApplicationContext());
                        HttpParams var40 = var38.getParams();
                        HttpConnectionParams.setConnectionTimeout(var40, 5000);
                        HttpConnectionParams.setSoTimeout(var40, 5000);
                        HttpPost var41 = new HttpPost("https://www.androbench.org/db_androbench/recorder_micro_v5.php");

                        try {
                            var41.setEntity(new UrlEncodedFormEntity(var24, "UTF-8"));
                            if (EntityUtils.toString(var38.execute(var41).getEntity()).equals("success")) {
                                Result.this.send_success_micro = true;
                            }
                        } catch (ClientProtocolException var48) {
                            var48.printStackTrace();
                        } catch (IOException var49) {
                            var49.printStackTrace();
                        }
                    } catch (Exception var50) {
                    }
                }
            }

            if (Result.this.flag_sqlitebench) {
                int var1 = 0;
                Result.this.send_success_sqlite = false;
                ArrayList var2 = new ArrayList();
                var2.add(new BasicNameValuePair("device_model", Build.MODEL.toString().replaceAll(" ", "%20")));
                var2.add(new BasicNameValuePair("avg_perf_insert", Double.toString(Result.this.avg_perf_sqlite_insert)));
                var2.add(new BasicNameValuePair("avg_perf_update", Double.toString(Result.this.avg_perf_sqlite_update)));
                var2.add(new BasicNameValuePair("avg_perf_delete", Double.toString(Result.this.avg_perf_sqlite_delete)));
                var2.add(new BasicNameValuePair("transaction_size", Integer.toString(Result.this.transactionSize)));
                var2.add(new BasicNameValuePair("journal_mode", Result.this.journalMode));
                byte var9;
                if (Result.this.indexUsage) {
                    var9 = 1;
                } else {
                    var9 = 0;
                }

                var2.add(new BasicNameValuePair("index_usage", Integer.toString(var9)));

                try {
                    var2.add(new BasicNameValuePair("androbench_ver", Result.this.mContext.getPackageManager().getPackageInfo(Result.this.mContext.getPackageName(), 0).versionName));
                } catch (NameNotFoundException var47) {
                    var2.add(new BasicNameValuePair("androbench_ver", "unknown"));
                }

                var2.add(new BasicNameValuePair("android_ver", VERSION.RELEASE));
                var2.add(new BasicNameValuePair("kernel_ver", VersionCheck.getKernelVersion()));
                var2.add(new BasicNameValuePair("build_ver", VERSION.INCREMENTAL));

                for (; var1 < 3 && !Result.this.send_success_sqlite; ++var1) {
                    try {
                        CustomHttpClient var16 = new CustomHttpClient(Result.this.getApplicationContext());
                        HttpParams var18 = var16.getParams();
                        HttpConnectionParams.setConnectionTimeout(var18, 5000);
                        HttpConnectionParams.setSoTimeout(var18, 5000);
                        HttpPost var19 = new HttpPost("https://www.androbench.org/db_androbench/recorder_sqlite_v5.php");

                        try {
                            var19.setEntity(new UrlEncodedFormEntity(var2, "UTF-8"));
                            if (EntityUtils.toString(var16.execute(var19).getEntity()).equals("success")) {
                                Result.this.send_success_sqlite = true;
                            }
                        } catch (ClientProtocolException var44) {
                            var44.printStackTrace();
                        } catch (IOException var45) {
                            var45.printStackTrace();
                        }
                    } catch (Exception var46) {
                    }
                }
            }

            Result.this.runOnUiThread(new Runnable() {
                public void run() {
                    if (!Result.this.send_success_micro && !Result.this.send_success_sqlite) {
                        Toast.makeText(Result.this.mContext, "Transmission failed", 0).show();
                    } else {
                        Toast.makeText(Result.this.mContext, "Transmission complete", 0).show();
                    }
                }
            });
        }
    }

    public static class ViewHolder {
        TextView btn;
        TextView name;
        TextView status;

        public ViewHolder() {
        }
    }
}
